package cn.ekgc.bmdsad.day8;

public class MyTreeSet {
    private MyNode root;

    class MyNode {
        private int data;
        private MyNode left;
        private MyNode right;

        public void add(MyNode node) {
            if (this.data > node.data) {
                if (this.left == null) {
                    this.left = node;
                } else {
                    this.left.add ( node );
                }
            }
            if (this.data < node.data) {
                if (this.right == null) {
                    this.right = node;
                } else {
                    this.right.add ( node );
                }
            }
        }

        public void zhongxu() {
            if (this.left != null) {
                this.left.zhongxu ();
            }
            System.out.println ( this.data );
            if (this.right != null) {
                this.right.zhongxu ();
            }
        }
    }
}